package com.badshun.stage;

import com.badlogic.gdx.scenes.scene2d.*;
import com.badshun.map.*;
import com.badlogic.gdx.graphics.*;
import com.badshun.box2d.*;
import com.badshun.player.*;
import com.badlogic.gdx.math.*;
import com.badlogic.gdx.*;

public class MainCityStage extends EnvironmentStage {
	private OrthographicCamera camera;
	
	public GameMap map;
	
	public static final String TAG = "MainCityStage";
	
	public boolean isActive;
	
	public NPCPlayersManager npm;
	
	public Enemy[] enemys;
	
	public MainCityStage(MainPlayer player,NPCPlayersManager npm,OrthographicCamera camera,Box2DWorld world) {
		
		super(player,camera,world);
		
		this.npm = npm;
		this.camera = camera;
		
		enemys = new Enemy[2];
		enemys[0] = new Enemy("小兵1",new Vector2(1000,1000),new Texture(Gdx.files.internal("player/enemy1.jpg")),world,player,camera);
		enemys[1] = new Enemy("小兵2",new Vector2(1500,1000),new Texture(Gdx.files.internal("player/enemy1.jpg")),world,player,camera);
		
		npm.createNPCPlayers(TAG,player,world,"data/mainCity.bdl",camera);
		
		map = new GameMap("map/mainCity.tmx",TAG,world,camera);
	}
	
	public void changeLength(int length) {
		Enemy[] copy = new Enemy[length];
		
		for(int i = 0; i < copy.length; i++) {
			copy[i] = enemys[i];
		}
		
		enemys = copy;
	}

	@Override
	public void draw() {
		map.render();
		
		npm.npcs.render();
		
		for(int i = 0; i < enemys.length; i++) {
			if(enemys[i].isDeath) {
				changeLength(enemys.length - 1);
			} else {
				enemys[i].render();
			}
		}
	}
}
